import axios from "axios";
import service from "@/config/index";

const URLS = {
  SEARCH: `${service.serviceBasic}/carrier/search`,
  IMPORT: `${service.serviceBasic}/carrier/readExcel`,
  BATCH_INSERT: `${service.serviceBasic}/carrier/batchInsert`,
  UPDATE: `${service.serviceBasic}/carrier/`,
  INVITE_CARRIER: `${service.serviceUser}/qrCode/tenant/invite`,
  INVITE_DRIVER: `${service.serviceUser}/qrCode/driver/invite`,
  OPEN_AUTO_BALANCE: `${service.serviceBasic}/carrier/openAutoBalance`,
  COLSE_AUTO_BALANCE: `${service.serviceBasic}/carrier/closeAutoBalance`,
};
export default {
  search (filter) {
    return axios.post(URLS.SEARCH, filter);
  },
  update (id, filter) {
    return axios.put(`${URLS.UPDATE}${id}`, filter);
  },
  importExcel (file) {
    return axios.post(URLS.IMPORT, file, { timeout: 200000 });
  },
  batchInsert (filter) {
    return axios.post(URLS.BATCH_INSERT, filter);
  },
  getCompany (code) {
    return axios.get(`${service.serviceTenant}/code/${code}`);
  },
  inviteCarrier (filter) {
    return axios.get(URLS.INVITE_CARRIER, filter);
  },
  inviteDriver (filter) {
    return axios.get(URLS.INVITE_DRIVER, filter);
  },
  // 对线上承运方开启委托对账
  openAutoBalance (filter) {
    return axios.put(URLS.OPEN_AUTO_BALANCE, filter);
  },
  // 对线上承运方关闭委托对账
  closeAutoBalance (filter) {
    return axios.put(URLS.COLSE_AUTO_BALANCE, filter);
  },
  getCarrierById (carrierId) {
    return axios.get(`${service.serviceBasic}/carrier/${carrierId}`);
  },
};
